package com.alex.ioc.factory;

import java.util.HashMap;
import java.util.Map;

/**
 * 实例工厂方法
 * 使用工厂前需要先实例化工厂
 */
public class InstantCarFactory {

    public Map<String, Car> cars = null;

    public InstantCarFactory() {
        cars = new HashMap<>();
        cars.put("audi", new Car("bmw", 300000.0));
        cars.put("bmw", new Car("bmw", 360000.0));
        cars.put("benz", new Car("benz", 450000.0));
    }

    public Car getCar(String name) {
        return cars.get(name);
    }
}
